﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace NDK.Frm
{

    public partial class Frm_InitItemStatu : Form
    {
        public Frm_InitItemStatu()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 窗体对象实例
        /// </summary>
        private static Frm_InitItemStatu _instance;
        internal static Frm_InitItemStatu Instance
        {
            get
            {
                if (_instance == null)
                    _instance = new Frm_InitItemStatu();
                return _instance;
            }
        }


        //更新进度
        internal void UpdateStep(int percentValue, string stepMsg, bool succeed)
        {
            try
            {
                Frm_Welcome.Instance .bar_step.Value = percentValue;

                if (succeed == true)
                {
                    Frm_Welcome.Instance.lbl_step.ForeColor = Color.GreenYellow;
                }
                else
                {
                    Frm_Welcome.Instance.lbl_step.ForeColor = Color.Red;
                }

                Frm_Welcome.Instance .lbl_step.Text = stepMsg + "...";

                int index = dataGridView1.Rows.Add();

                string temp = stepMsg;
                string temp1 = "";
                temp1 = temp1 + (succeed ? "√" : "×");
                dataGridView1.Rows[index].Cells[0].Value = temp;
                dataGridView1.Rows[index].Cells[1].Value = temp1;

                dataGridView1.Rows[index].Cells[0].Style.ForeColor = (succeed == true ? Color.Green : Color.Red);
                dataGridView1.Rows[index].Cells[1].Style.ForeColor = (succeed == true ? Color.Green : Color.Red);
                Application.DoEvents();
            }
            catch (Exception ex)
            {
            }
        }
        private void Frm_InitItemStatu_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Hide();
            e.Cancel = true;
        }
    }
}
